/**
 * 动态切换加载页面
 */
function switch_page(name, p, cb) {
    if (!context.center.cache) context.center.cache = {};

    var f = function(r) {
        if (!p) {
            $("#game").empty();
            $("#game").html(r);
        }
        else
            p.html(r);
        if (!window.magicFlag) {
            $('input[type="checkbox"]').uCheck();
            $('input[type="radio"]').uCheck();

            var arr = $("select");
            for (var i = 0; i < arr.length; i++) {
                if ($(arr[i]).attr("denyau") == 1) continue;
                $(arr[i]).selected();
            }
        }
        
        $(".am-popover").remove();
        if (cb) cb();
    };

    if (context.center.cache[name]) {
        console.log("load from cache.", name);
        f(context.center.cache[name]);
    } 
    else {
        $.get(context.config.page_url + name + ".html", function(r) {
            context.center.cache[name] = r;
            f(r);
        });
    }
}

function preload_page(name) {
    if (!context.center.cache) context.center.cache = {};
    if (context.center.cache[name]) {
        return;
    }
    $.get(context.config.page_url + name + ".html", function(r) {
        context.center.cache[name] = r;
    });
}